/***************************************************************************
 *   This file is part of KLabeler                                         *
 *   Copyright (C) 2010 by Luca Bellonda                                   *
 *   lbellonda _at_ gmail.com                                              *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include "tagProfile.h"

TagProfile::TagProfile()
{
    type = ALLACTIVITIES ;
}

TagProfile::TagProfile(const QString &newName)
{
    name = newName ;
    description = newName ;
    type = ONEACTIVITY ;
    createdOn = QDateTime::currentDateTime();
    updatedOn = QDateTime::currentDateTime();
    enabled = true ;
}

TagProfile::~TagProfile()
{
}

const QString & TagProfile::getId()
{
    return id ;
}

const QString & TagProfile::getName()
{
    return name ;
}

const QString & TagProfile::getDescription()
{
    return description ;
}

TagProfile::ESessionType TagProfile::getType()
{
    return type ;
}

QStringList &TagProfile::getTags()
{
    return tags;
}

QStringList &TagProfile::getActivities()
{
    return activities ;
}

bool TagProfile::isEnabled()
{
    return enabled ;
}

//------------- setters

void TagProfile::setId(const QString & newId)
{
    id = newId ;
}

void TagProfile::setName(const QString & newName)
{
    name = newName ;
}

void TagProfile::setDescription(const QString & newDescription)
{
    description = newDescription ;
}

void TagProfile::setType(const TagProfile::ESessionType newType)
{
    type = newType ;
}

void TagProfile::setCreatedOn(const QDateTime &value)
{
    createdOn = value ;
}

void TagProfile::setUpdatedOn(const QDateTime &value)
{
    updatedOn = value ;
}

//----------------------------------------------------------------------------------------

void TagProfile::addActivity(const QString &activity)
{
    activities.append(activity);
}

void TagProfile::addTag(const QString &tag)
{
    tags.append(tag);
}

void TagProfile::setTags(QStringList list)
{
    tags = list ;
}

void TagProfile::setActivities(QStringList list)
{
    activities = list ;
}

void TagProfile::resetTags()
{
    tags.clear();
}

void TagProfile::resetActivities()
{
    activities.clear();
}

bool TagProfile::isActivity(const QString &activityName)
{
    bool result = activities.contains(activityName);
    return result ;
}

void TagProfile::setEnabled(const bool how)
{
    enabled = how ;
}

//----------------------------------------------------------------------------------------

TagProfile* TagProfile::getMockUp(const QString &name)
{
    static int i = 0;
    TagProfile* profile = new TagProfile();
    i++;
    profile->id = i;
    profile->name = name ;
    profile->type = (ESessionType)((((int)ALLACTIVITIES) + i) % 3) ;
    profile->tags.append("uno") ;
    profile->tags.append("due") ;
    profile->tags.append(name) ;
    profile->activities.append("app-uno") ;
    profile->updatedOn = QDateTime::currentDateTime() ;
    profile->createdOn = QDateTime::currentDateTime() ;

    return profile ;
}

//----------------------------------------------------------------------------------------
void TagProfile::deleteProfiles(QVector<TagProfile*> *profiles)
{
    if (NULL == profiles) {
        return ;
    }
    int size = profiles->size();
    for (int i = 0; i < size; i++) {
        TagProfile* profile = profiles->at(i) ;
        delete profile ;
    }
    profiles->clear();
    delete profiles;
}
/*
void TagProfile::apply(QVector<TagProfile*> *profiles, void (*funct)(TagProfile*) )
{
    if (NULL == profiles) {
        return ;
    }
    int size = profiles->size();
    for (int i = 0; i < size; i++) {
        TagProfile* profile = profiles->at(i) ;
        funct(profile()) ;
    }
}
*/
